< previous page page_218 next page >

Page 218
Besides the different constants for the icons, you can add to this parameter the constants for the buttons you want to appear. Table 11.2 presents a list of the different constants you can use for the buttons.
Table 11.2 Constants for the Buttons on the MsgBox.
Button ConstantDescription
vbOkOnlyDisplays the OK button only. This is the default.
vbOkCancelDisplays both the OK and Cancel buttons.
vbYesNoDisplays the Yes and No buttons.
vbYesNoCancelDisplays the Yes, No, and Cancel buttons.
vbRetryCancelDisplays the Retry and Cancel buttons.
vbAbortRetryCancelDisplays the Abort, Retry, and Cancel buttons.
vbMsgBoxHelpButtonAdds the Help button to the MsgBox.

You can specify which button is the default button on the message box. This is accomplished by adding to the second parameter one of the vbDefaultButtonn constants. The n is the number of the button to set the focus to and can be a value from 1 to 4.
9f31265bb40b592b1929e18a47ab28e5.gif
intButton = MsgBox("Save Data", vbQuestion + vbYesNo, "Save"
You can try out some of the options by loading the sample project for this chapter and clicking the MsgBox command button on the main form to display a sample message box, as shown in Figure 11.1.
Examples Filename: MsgBox.frm
When you click the first command button on the MsgBox.frm sample form, youll see a message box appear (see Figure 11.1).
8160-0218a.gif
Figure 11.1
A simple 
MsgBox example.
You might use this simple type of message box when a long process completes or when you just need to inform the user of some simple information that needs an acknowledgment.

 
< previous page page_218 next page >

If you like this book, buy it!